home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 12 - 1996 / 12.02 Feb 96 / 12.02 Getting Started / beepCommander.cp next >
Encoding:
Text File  |  1995-11-21  |  4.2 KB  |  155 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    <PP Starter Source>.cp         ©1994-1995 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    This file contains the starter code for a PowerPlant application
  6.  
  7. #include "<PP Starter Header>.h"
  8.  
  9. #include <LGrowZone.h>
  10. #include <LWindow.h>
  11. #include <PP_Messages.h>
  12. #include <PP_Resources.h>
  13. #include <PPobClasses.h>
  14. #include <UDrawingState.h>
  15. #include <UMemoryMgr.h>
  16. #include <URegistrar.h>
  17. #include <LEditField.h>
  18. #include "CSingleCharPane.h"
  19.  
  20.  
  21. // put declarations for resource ids (ResIDTs) here
  22.  
  23. const ResIDT    window_Sample        = 1000;    // EXAMPLE
  24.  
  25.  
  26. // ===========================================================================
  27. //        • Main Program
  28. // ===========================================================================
  29.  
  30. void main(void)
  31. {
  32.                                     // Set Debugging options
  33.     SetDebugThrow_(debugAction_Alert);
  34.     SetDebugSignal_(debugAction_Alert);
  35.  
  36.     InitializeHeap(3);                // Initialize Memory Manager
  37.                                     // Parameter is number of Master Pointer
  38.                                     //   blocks to allocate
  39.     
  40.                                     // Initialize standard Toolbox managers
  41.     UQDGlobals::InitializeToolbox(&qd);
  42.     
  43.     new LGrowZone(20000);            // Install a GrowZone function to catch
  44.                                     //    low memory situations.
  45.  
  46.     CPPStarterApp    theApp;            // replace this with your App type
  47.     theApp.Run();
  48. }
  49.  
  50.  
  51. // ---------------------------------------------------------------------------
  52. //        • CPPStarterApp             // replace this with your App type
  53. // ---------------------------------------------------------------------------
  54. //    Constructor
  55.  
  56. CPPStarterApp::CPPStarterApp()
  57. {
  58.     // Register functions to create core PowerPlant classes
  59.     URegistrar::RegisterClass( CSingleCharPane::class_ID, CSingleCharPane::CreateSingleCharPaneStream );
  60.     RegisterAllPPClasses();
  61. }
  62.  
  63.  
  64. // ---------------------------------------------------------------------------
  65. //        • ~CPPStarterApp            // replace this with your App type
  66. // ---------------------------------------------------------------------------
  67. //    Destructor
  68. //
  69.  
  70. CPPStarterApp::~CPPStarterApp()
  71. {
  72. }
  73.  
  74. // ---------------------------------------------------------------------------
  75. //        • StartUp
  76. // ---------------------------------------------------------------------------
  77. //    This function lets you do something when the application starts up. 
  78. //    For example, you could issue your own new command, or respond to a system
  79. //  oDoc (open document) event.
  80.  
  81. void
  82. CPPStarterApp::StartUp()
  83. {
  84.     ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  85. }
  86.  
  87. // ---------------------------------------------------------------------------
  88. //        • ObeyCommand
  89. // ---------------------------------------------------------------------------
  90. //    Respond to commands
  91.  
  92. Boolean
  93. CPPStarterApp::ObeyCommand(
  94.     CommandT    inCommand,
  95.     void        *ioParam)
  96. {
  97.     Boolean        cmdHandled = true;
  98.  
  99.     switch (inCommand) {
  100.     
  101.         // Deal with command messages (defined in PP_Messages.h).
  102.         // Any that you don't handle will be passed to LApplication
  103.              
  104.         case cmd_New:
  105.                                         // EXAMPLE, create a new window
  106.             LWindow        *theWindow;
  107.             theWindow = LWindow::CreateWindow(window_Sample, this);
  108. //    New code from Dave Mark for Feb '95 column
  109.             CSingleCharPane    *theCharPane = (CSingleCharPane *)theWindow->FindPaneByID( 2000 );
  110.             theWindow->SetLatentSub( theCharPane );
  111.  //    End of new code
  112.             theWindow->Show();
  113.             break;
  114.  
  115.  
  116.  
  117.         default:
  118.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  119.             break;
  120.     }
  121.     
  122.     return cmdHandled;
  123. }
  124.  
  125. // ---------------------------------------------------------------------------
  126. //        • FindCommandStatus
  127. // ---------------------------------------------------------------------------
  128. //    This function enables menu commands.
  129. //
  130.  
  131. void
  132. CPPStarterApp::FindCommandStatus(
  133.     CommandT    inCommand,
  134.     Boolean        &outEnabled,
  135.     Boolean        &outUsesMark,
  136.     Char16        &outMark,
  137.     Str255        outName)
  138. {
  139.  
  140.     switch (inCommand) {
  141.     
  142.         // Return menu item status according to command messages.
  143.         // Any that you don't handle will be passed to LApplication
  144.  
  145.         case cmd_New:                    // EXAMPLE
  146.             outEnabled = true;            // enable the New command
  147.             break;
  148.  
  149.         default:
  150.             LApplication::FindCommandStatus(inCommand, outEnabled,
  151.                                                 outUsesMark, outMark, outName);
  152.             break;
  153.     }
  154. }
  155.